package tuioZones;

import java.util.ArrayList;

import processing.core.PApplet;
import tuioZones.PointXY;

public class TouchPoint {
	private PointXY primePoint;
	private int SID;
	private TouchZone zone;
	private ArrayList<PointXY> history;

	TouchPoint(PApplet myParent,int SidIn, float xIn, float yIn, TouchZone zone) {
		this.primePoint = new PointXY(xIn,yIn);// x coordinate
		SID = SidIn;// SID from TUIO
		history = new ArrayList<PointXY>();
		this.zone = zone;
		// transform zones
		//markZone(tpointIn, zone);// try to take ownership of a zone

	}

	// create a trail of points (history) for this touch point
	void addPoint(int SidIn, float xIn, float yIn) {
		history.add(new PointXY(xIn,yIn));
		SID = SidIn;
	}

	// get the last point in trail - return x,y coordinates and velocities
	PointXY getLastPoint() {
		if(history.size() == 0)
			return primePoint;
		return history.get(history.size() -1);
	}

	// get the first point in trail
	PointXY getFirstPoint() {
		return primePoint;
	}
	
	public float getX() {
		return getLastPoint().getX();
	}
	
	public float getY() {
		return getLastPoint().getY();
	}

	/**
	 * @return the sID
	 */
	public int getSID() {
		return SID;
	}

	/**
	 * @param sid the sID to set
	 */
	public void setSID(int sid) {
		SID = sid;
	}

	/**
	 * @return the zone
	 */
	public TouchZone getZone() {
		return zone;
	}
	
	public ArrayList<PointXY> getHistory() {
		return history;
	}
}
